package com.ttg.model.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ttg.model.pojo.BankAgent;
import com.ttg.model.vo.BankAgentListVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * @author zhangHongYuan
 * @description
 * @date 2023/6/8 11:19
 */
public interface BankAgentMapper extends BaseMapper<BankAgent> {


    @Delete("truncate table tbl_bank_agent")
    void truncate();

    @Update("update tbl_bank_agent a join tbl_bank_agent p on p.bank_agent_no = a.bank_agent_parent_no\n" +
            "set a.bank_agent_no0 = p.bank_agent_no0\n" +
            "where  a.bank_agent_level = '2'")
    void updateAgentNoLevel2();

    @Update("update tbl_bank_agent a join tbl_bank_agent p on p.bank_agent_no = a.bank_agent_parent_no\n" +
            "set a.bank_agent_no1 = p.bank_agent_no1\n" +
            "    ,a.bank_agent_no0 = p.bank_agent_no0\n" +
            "where  a.bank_agent_level = '3'")
    void updateAgentNoLevel3();

    @Update("update tbl_bank_agent a join tbl_bank_agent p on p.bank_agent_no = a.bank_agent_parent_no\n" +
            "set a.bank_agent_no2 = p.bank_agent_no2\n" +
            "    ,a.bank_agent_no1 = p.bank_agent_no1\n" +
            "    ,a.bank_agent_no0 = p.bank_agent_no0\n" +
            "where  a.bank_agent_level = '4'")
    void updateAgentNoLevel4();
    List<BankAgentListVo> bankAgentList();
}
